package com.demo.minio.test;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * @author lkz
 * @ClassName: Person
 * @description: TODO
 * @date 2022/4/21 16:02
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Person {


    private String firstName, lastName, job, gender;
    private int age,salary;



    public static void main(String[] args) {
        List<Person> perList = new ArrayList<Person>() {
            {
                add(new Person("Elsdon", "Jaycob", "Java programmer", "male", 43, 2000));
                add(new Person("Tamsen", "Brittany", "Java programmer", "female", 23, 1500));
                add(new Person("Floyd", "Donny", "Java programmer", "male", 33, 1800));
                add(new Person("Sindy", "Jonie", "Java programmer", "female", 32, 1600));
                add(new Person("Vere", "Hervey", "Java programmer", "male", 22, 1200));
                add(new Person("Maude", "Jaimie", "Java programmer", "female", 27, 1900));
                add(new Person("Shawn", "Randall", "Java programmer", "male", 30, 2300));
                add(new Person("Jayden", "Corrina", "Java programmer", "female", 35, 1700));
                add(new Person("Palmer", "Dene", "Java programmer", "male", 33, 2000));
                add(new Person("Addison", "Pam", "Java programmer", "female", 34, 1300));
            }
        };
        // 筛选工资大于1500
//        Set<String> collect = perList.stream().filter(person -> person.getSalary() > 1500).
//                map(Person::getFirstName).collect(Collectors.toSet());
        // 按照姓名排序
       // List<Person> collect = perList.stream().sorted((p,p2)->(p.getFirstName().compareTo(p2.getFirstName()))).limit(5).collect(Collectors.toList());
       // 根据名字转化map
       // Map<String, Person> collect = perList.stream().map(person -> person).collect(Collectors.toMap(Person::getFirstName, p -> p));
        // 排序升序
        //List<Person> collect = perList.stream().sorted((o1, o2) -> o1.getSalary() - o2.getSalary()).collect(Collectors.toList());
       // 判断是否有重复的名称
        boolean addison = perList.stream().anyMatch(person -> person.getFirstName().equals("Addison"));
        // System.out.println(collect);





    }
}
